package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ConsumerController {

    //查询资源
    @RequestMapping("/query")
    @ResponseBody
    public String queryUser(){

        RpcClientProxy rpcClientProxy = RpcClientProxy.getInstance();

        IUserService userService = (IUserService) rpcClientProxy.createProxy(IUserService.class);
        User user = userService.getById(1);
        System.out.println(user);

        return user.toString();
    }

}



